import React, { Component } from "react";
import './style.scss';


interface LoginProps {
  onSuccess?: Function;
}
export default ({onSuccess = () => {}}: LoginProps) => {

  return (
    <>
      <LoginFormComponent type="phone" />
    </>
  )
};

interface LoginFormComponentProps {
  type: 'phone' | 'email';
  onSuccess?: Function;
}

export class LoginFormComponent extends Component<LoginFormComponentProps> {
  private service: any = null;

  constructor(props: LoginFormComponentProps) {
    super(props);
    const type = props.type || 'email';
    this.service = type === 'phone' ? 'phone' : 'email';
  }

  render() {
    if(!this.service){ return null };
    return (
      <LoginForm loginService={this.service} {...this.props} />
    )
  }
}

interface LoginFormProps {
  type: 'phone' | 'email';
  loginService: any;
  onSuccess?: Function;
}

const LoginForm = ({
  type,
  loginService,
  onSuccess = () => {},
}: LoginFormProps) => {
  return (
    <div>
      login compomemt
    </div>
  )
};
